#pragma once

#include <string>

namespace cybertron {

	class LogItem
	{
	public:
		LogItem() {};
		virtual ~LogItem() {};

		virtual std::string to_net_message() = 0;
		virtual int from_net_message(const std::string message) = 0;

		virtual std::string to_file_line() = 0;
		virtual std::string to_local_file_line() = 0;
		virtual int from_file_line(const std::string message) = 0;

		virtual size_t category_id() = 0;
	public:
		int _version;
	};

	class LogItemBuilder
	{
	public:
		static LogItem *build_item_from_net_message(const std::string message);
	};

	class LogItemV1 : public LogItem
	{
	public:
		LogItemV1();
		LogItemV1(const LogItemV1 &item);
		LogItemV1(const std::string & category, const std::string & producer, const std::string &level, const std::string &message);
		virtual ~LogItemV1() {};

		std::string to_net_message();
		int from_net_message(const std::string message);

		std::string to_file_line();
		std::string to_local_file_line();
		int from_file_line(const std::string message);

		size_t category_id();

		int64_t _time_stamp;
		std::string _category;
		std::string _producer;
		std::string _pid;
		std::string _level;
		//std::string _code;
		std::string _message;

		const char _message_delimiter = '\u0001';
		const std::string _file_line_delimiter = ": ";
	};
}